package br.com.harley.torneio.domain;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.EnumType;
import javax.persistence.Enumerated;
import javax.persistence.Inheritance;
import javax.persistence.InheritanceType;
import javax.persistence.Table;
import javax.persistence.Transient;
import javax.persistence.UniqueConstraint;

@Entity(name = "usuario")
@Inheritance(strategy = InheritanceType.JOINED)
@Table(name = "usuario", uniqueConstraints = { @UniqueConstraint(columnNames = { "login" }),
		@UniqueConstraint(columnNames = { "cpf" }) })
public class Usuario extends BasePojo {

	@Transient
	private static final long serialVersionUID = 1L;

	@Column(name = "login", length = 16, nullable = false)
	private String login;

	@Column(name = "senha", length = 64, nullable = false)
	private String senha;

	@Transient
	private String confirmacaoSenha;

	@Column(name = "nome", length = 160, nullable = false)
	private String nome;

	@Column(name = "cpf", length = 11, nullable = false)
	private String cpf;

	@Column(name = "email", length = 255, nullable = false)
	private String email;

	@Column(name = "senha_auto")
	private boolean senhaAuto;

	@Column(name = "papel")
	@Enumerated(EnumType.ORDINAL)
	private Papel papel;

	public Usuario() {
		super();
		papel = Papel.USUARIO;
	}

	@Override
	public String toString() {
		return "Usuario [" + super.toString() + ", login=" + login + ", cpf=" + cpf + "]";
	}

	public String getCpf() {
		return cpf;
	}

	public void setCpf(String cpf) {
		this.cpf = cpf;
	}

	public String getNome() {
		return nome;
	}

	public void setNome(String nome) {
		this.nome = nome;
	}

	public String getEmail() {
		return email;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	public String getLogin() {
		return login;
	}

	public void setLogin(String login) {
		this.login = login;
	}

	public String getSenha() {
		return senha;
	}

	public void setSenha(String senha) {
		this.senha = senha;
	}

	public boolean isSenhaAuto() {
		return senhaAuto;
	}

	public void setSenhaAuto(boolean senhaAuto) {
		this.senhaAuto = senhaAuto;
	}

	public Papel getPapel() {
		return papel;
	}

	public void setPapel(Papel papel) {
		this.papel = papel;
	}

	public String getConfirmacaoSenha() {
		return confirmacaoSenha;
	}

	public void setConfirmacaoSenha(String confirmacaoSenha) {
		this.confirmacaoSenha = confirmacaoSenha;
	}

}
